<template>
  <div @click="$router.push('/details/' + article.art_id)">
    <van-cell>
      <template #title>
        <div class="title-box">
          <span>{{ article.title }}</span>
          <img
            :src="article.cover.images[0]"
            alt=""
            class="thumb"
            v-if="article.cover.type === 1"
          />
        </div>

        <div class="thumb-box" v-if="article.cover.type === 3">
          <img
            class="thumb"
            v-lazy="item"
            v-for="(item, index) in article.cover.images"
            :key="index"
            alt=""
          />
        </div>
      </template>

      <template #label>
        <div class="label-box">
          <span
            >{{ article.aut_name }}&nbsp;&nbsp;
            {{ article.comm_count }} 评论&nbsp;&nbsp;
            {{ article.pubdate | relativeTime }}</span
          >
        </div>
      </template>
    </van-cell>
  </div>
</template>

<script>
export default {
  name: 'ArticleItem',
  data() {
    return {}
  },
  props: ['article'],

  components: {},

  computed: {},

  mounted() {},

  methods: {}
}
</script>
<style lang="less" scoped>
.label-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.thumb {
  // 矩形黄金比例：0.618
  width: 226px;
  height: 140px;
  background-color: #f8f8f8;
  object-fit: cover;
}

.title-box {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.thumb-box {
  display: flex;
  justify-content: space-between;
}

.center-title {
  text-align: center;
}
</style>
